<?php

// 获取订单分页列表
// GET ctrl.order.volist
// http://sg.io/api?ctrl.order.volist

namespace app\api\resource\ctrl\order;
use think\Db;
use app\api\lib\Page;

class Volist
{
    // 方法
    public $_method = ['GET'];
    // 前置
    public $_pre    = [];
    // public $_pre    = ['member'];
    // 描述
    public $_description = '获取订单分页列表';
    // 参数
    public $_param  = [
        'page' => '请求页,默认1',
        'show' => '请求记录数量,默认20',
    ];

    public function run(&$request)
    {
        $page  = $request->get('page/d',1);
        $show  = $request->get('show/d',20);

        $table    = 'order';
        $where[]  = ['status','=',1];
        $where[]  = ['money','neq',0.01];
        $order    = 'id DESC';
        $pagelist = Page::run($table,$where,$order,$page,$show);
        if ( !empty($pagelist['list']) ) {
            $pagelist['total_money'] = Db::name('order')->where($where)->sum('money');
        }

        // p($pagelist);die;

        return [200,$pagelist];
    }
}
